/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2017_11_01			*/
/*	File:		CmAdxEng.h			*/
/********************************************************/

#ifndef	_CMADXENG_H
#define	_CMADXENG_H

#include <getopt.h>
#include <signal.h>

#include "CmTcp.h"
#include "CmSet.h"
#include "CmUtil.h"
#include "CmTime.h"
#include "CmThread.h"

#include "CmAdmin.h"
#include "CmEvent.h"
#include "CmKafka.h"
#include "CmProPb.h"
#include "CmRedis.h"
#include "CmConfig.h"
#include "CmProJsn.h"
#include "CmLogger.h"

#define	CM_ADX_RRNN		0x03

#define	CM_ADX_CRLF		const_cast<char*>("\r\n")
#define	CM_ADX_NULL		const_cast<char*>("NULL")
#define	CM_ADX_DSPS		const_cast<char*>("avdsps")
#define CM_ADX_VERS		const_cast<char*>("CmAdxEng-1.0.0")
#define	CM_ADX_CTSZ		const_cast<char*>("Content-Length:")
#define	CM_ADX_POST		const_cast<char*>("POST / HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (compatible; Group/1.0; Linux)\r\nAccept: */*\r\nConnection: Keep-Alive\r\nContent-Type: application/json;charset=utf-8\r\nContent-Length: %d\r\n\r\n")

#define	CM_ADX_GETV(V, P)	((V) >> (P) & 1)
#define	CM_ADX_SET1(V, P)	((V) |= 1 << (P))
#define	CM_ADX_SET0(V, P)	((V) &= ~(1 << (P)))

void CmAdxEngQuit(int iSignal);
void* CmAdxEngThread(void* pPara);
ULONG CmAdxEngGetTrans(CMSTR_C& rCId);
void CmAdxEngWriteLog(CMADXPARA_S* pstPara);
int CmAdxEngDistribute(CMADXPARA_S* pstPara);
CMADXPARA_S* CmAdxEngRequest(struct evhttp_request* pstReq);
void CmAdxEngCore(struct evhttp_request* pstReq, void* pNULL);
int CmAdxEngHttpParse(CMADXMSG_S* pstRecv, CMADXMSG_S* pstTemp);
void CmAdxEngBidPrice(CmCls::CCmSet& rCOffer, CMADXPARA_S* pstPara);
int CmAdxEngSetTimOut(struct timeval* pstTim, struct timeval* pstOut);
int CmAdxEngResponse(struct evhttp_request* pstReq, CMADXPARA_S* pstPara);

#endif /* _CMADXENG_H */
